package work4;

import java.util.Scanner;
import java.util.Random;

public class Quetion1 {
	public static void main(String[] args) {
		int cnt = 0;
		long time = 0;
		Random r = new Random();
		int random_num = Math.abs(r.nextInt() % 101);

		Scanner input = new Scanner(System.in);

		long t = System.currentTimeMillis();
		while (true) {
			System.out.println("请输入你要猜的数字：");
			int num = input.nextInt();
			cnt++;
			if (num < random_num) {
				System.out.println("系统提示！您输入的数字偏小");

			} else if (num > random_num) {
				System.out.println("系统提示！您输入的数字偏大");
			} else {
				time = System.currentTimeMillis() - t;
				break;
			}
		}

		input.close();
		System.out.printf("你猜了%d次\n", cnt);
		System.out.printf("您花了%d毫秒\n", time);
	}
}
